package utill;

import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

import java.io.IOException;

public class switchpages {

    /**
     * @Param actionEvent : 事件
     * @Param uri :相对文件地址;
     * 切换页面;
     */
      public void switch_view(ActionEvent actionEvent ,String uri) throws IOException {
               AnchorPane other = FXMLLoader.load(getClass().getResource(uri));
              ((Button)actionEvent.getSource()).getScene().setRoot(other);
      }



   public void switch_viewPane(Pane pane ,String uri) throws Exception {
         start(pane,uri);
   }


    public void start(Pane pane ,String uri) throws Exception{
        //加载fxml文件;
        Parent root = FXMLLoader.load(getClass().getResource(uri));
        pane.getChildren().setAll(root);
    }

}
